App.require(function () {
    var app = App.getCurrent();
    var popUp = null;

    app.definePopUp("strloader", {
        exitEnd: function (ev) {
            popUp = null;
            if (app.isLock) app.unlock();
        },
        changeContent: function (content) {
            if (this.currentPage.changeContent) this.currentPage.changeContent(content);
        },
        changeOption: function (option) {
            if (this.currentPage.changeOption) this.currentPage.changeOption(option);
            this._setDuration(option.duration);
        },
        _setDuration: function (duration) {
            var that = this;
            if (duration) {
                if (app.isLock) app.unlock();
                setTimeout(function () {
                    that.hidden();
                }, duration);
            }
            else {
                if (!app.isLock) app.lock();
            }
        },
        initPopup: function () {
        },
        beforeShow: function () {
            if (document.activeElement) document.activeElement.blur();
            if (popUp) {
                App.extend(popUp.data, this.data);
                popUp.changeContent(this.data.content);
                popUp.changeOption(this.data.option);
                if (typeof this.data.bk === "function") this.data.bk(popUp); 
                return false;
            }
            popUp = this;
            this._setDuration(this.data.option.duration);
            return true;
        },
    });
})